home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / office german / PROPLUS.WW / PROPLSWW.CAB / FL_Compsvcspkg_dll_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 / RCDATA / 2049
Extensible Markup Language  |  2006-10-26  |  11KB  |  243 lines

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  3.     xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:s="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="wsdl ms s">
  4.     <xsl:output method="xml"
  5.         omit-xml-declaration = "yes"/>
  6.  
  7.     <!--
  8.     =========================================================
  9.     We do use two pass xsl transform to produce pretty HTM out of wsdl
  10.     files. this stylesheet is used at pass 1. It will produce a single XML
  11.     output that will contain all the data the second pass will need to produce the
  12.     HTM. We still does not support all the posible cases that could be expressed
  13.     by wsdl schema. For example messages with multiple parts or tyreferences in the type
  14.  
  15.  
  16.     =========================================================
  17.     -->
  18.  
  19.  
  20.  
  21.     <xsl:template match="/">
  22.         <wsdl>
  23.             <definitions>
  24.                 <xsl:apply-templates select="/" mode= "collect"/>
  25.             </definitions>
  26.         </wsdl>
  27.     </xsl:template>
  28.  
  29.  
  30.     <xsl:template match="wsdl:definitions" mode="collect">
  31.  
  32.         <!-- walk the imports  -->
  33.         <xsl:for-each  select="wsdl:import">
  34.  
  35.             <xsl:apply-templates select="document(@location)" mode="collect"/>
  36.         </xsl:for-each>
  37.  
  38.  
  39.         <!--
  40.         =========================================================
  41.         colect what we need from service node[s]
  42.         =========================================================
  43.         -->
  44.         <xsl:for-each  select="wsdl:service">
  45.             <service>
  46.  
  47.                 <xsl:attribute name="name">
  48.                     <xsl:value-of select="@name" />
  49.                 </xsl:attribute>
  50.  
  51.  
  52.  
  53.                 <!-- save the documentation node if any  -->
  54.                 <xsl:if test="wsdl:documentation">
  55.                     <documentation>
  56.                         <xsl:value-of select="."/>
  57.                     </documentation>
  58.                 </xsl:if>
  59.  
  60.             </service>
  61.         </xsl:for-each>
  62.  
  63.         <!--
  64.         =========================================================
  65.         colect what we need from portType node[s]
  66.         =========================================================
  67.         -->
  68.         <xsl:for-each  select="wsdl:portType">
  69.             <portType>
  70.  
  71.                 <xsl:attribute name="name">
  72.                     <xsl:value-of select="@name" />
  73.                 </xsl:attribute>
  74.  
  75.  
  76.                 <!-- collect all the methods -->
  77.                 <xsl:for-each   select="wsdl:operation">
  78.                     <operation>
  79.                         <xsl:attribute name="name">
  80.                             <xsl:value-of select="@name" />
  81.                         </xsl:attribute>
  82.  
  83.                         <!-- for each method we need the message name for the input and output messages
  84.                              (used to build the argument list and return type of the method)
  85.                              as well as content of description node if exist
  86.                         -->
  87.  
  88.                         <xsl:if test="wsdl:input">
  89.                             <input>
  90.                                 <xsl:attribute name="message">
  91.                                     <!-- strip the namespace if any -->
  92.                                     <xsl:choose>
  93.                                         <xsl:when test = "contains(wsdl:input/@message, ':')">
  94.                                             <xsl:value-of select="substring-after(wsdl:input/@message, ':')" />
  95.                                         </xsl:when>
  96.                                         <xsl:otherwise>
  97.                                             <xsl:value-of select="wsdl:input/@message" />
  98.                                         </xsl:otherwise>
  99.                                     </xsl:choose>
  100.                                 </xsl:attribute>
  101.                             </input>
  102.                         </xsl:if>
  103.  
  104.                         <xsl:if test="wsdl:output">
  105.                             <output>
  106.                                 <xsl:attribute name="message">
  107.                                     <!-- strip the namespace if any -->
  108.                                     <xsl:choose>
  109.                                         <xsl:when test = "contains(wsdl:output/@message, ':')">
  110.                                             <xsl:value-of select="substring-after(wsdl:output/@message, ':')" />
  111.                                         </xsl:when>
  112.                                         <xsl:otherwise>
  113.                                             <xsl:value-of select="wsdl:output/@message" />
  114.                                         </xsl:otherwise>
  115.                                     </xsl:choose>
  116.                                 </xsl:attribute>
  117.                             </output>
  118.                         </xsl:if>
  119.  
  120.                         <xsl:if test="wsdl:documentation">
  121.                             <documentation>
  122.                                 <xsl:value-of select="."/>
  123.                             </documentation>
  124.                         </xsl:if>
  125.  
  126.                     </operation>
  127.                 </xsl:for-each>
  128.  
  129.             </portType>
  130.         </xsl:for-each>
  131.  
  132.         <!--
  133.         =========================================================
  134.         colect what we need from messages node[s]
  135.         =========================================================
  136.         -->
  137.         <xsl:for-each  select="wsdl:message">
  138.             <message>
  139.  
  140.                 <xsl:attribute name="name">
  141.                     <xsl:value-of select="@name" />
  142.                 </xsl:attribute>
  143.  
  144.  
  145.                 <!--
  146.                     collect the parts - only the first part used  and we support only the element attribute
  147.                     type attribute is ignored.
  148.                     we add it as an atribute to the Message element
  149.                 -->
  150.                 <xsl:if test="wsdl:part">
  151.                     <xsl:attribute name="element">
  152.                         <xsl:choose>
  153.                             <!-- strip the namespace if any -->
  154.                             <xsl:when test = "contains(wsdl:part/@element, ':')">
  155.                                 <xsl:value-of select="substring-after(wsdl:part/@element, ':')" />
  156.                             </xsl:when>
  157.                             <xsl:otherwise>
  158.                                 <xsl:value-of select="wsdl:part/@element" />
  159.                             </xsl:otherwise>
  160.                         </xsl:choose>
  161.                     </xsl:attribute>
  162.                    </xsl:if>
  163.             </message>
  164.         </xsl:for-each>
  165.  
  166.         <!--
  167.         =========================================================
  168.         colect what we need from type node
  169.         =========================================================
  170.         -->
  171.         <xsl:for-each  select="wsdl:types">
  172.             <types>
  173.                 <schema>
  174.                     <xsl:for-each  select="s:schema/s:element">
  175.                         <element>
  176.                             <xsl:attribute name="name">
  177.                                 <xsl:value-of select="@name" />
  178.                             </xsl:attribute>
  179.  
  180.                             <xsl:if test="@type">
  181.                                 <xsl:attribute name="type">
  182.                                     <!-- strip the namespace if any -->
  183.                                     <xsl:choose>
  184.                                         <xsl:when test = "contains(@type, ':')">
  185.                                             <xsl:value-of select="substring-after(@type, ':')" />
  186.                                         </xsl:when>
  187.                                         <xsl:otherwise>
  188.                                             <xsl:value-of select="@type" />
  189.                                         </xsl:otherwise>
  190.                                     </xsl:choose>
  191.                                 </xsl:attribute>
  192.                              </xsl:if>
  193.  
  194.                             <xsl:if test="s:complexType/s:sequence/s:element">
  195.                                 <complexType>
  196.                                     <sequence>
  197.                                             <xsl:for-each  select="s:complexType/s:sequence/s:element">
  198.                                                 <element>
  199.                                                     <xsl:attribute name="name">
  200.                                                         <xsl:value-of select="@name" />
  201.                                                     </xsl:attribute>
  202.                                                     <xsl:if test="@type">
  203.                                                         <!-- strip the namespace if any -->
  204.                                                         <xsl:attribute name="type">
  205.                                                             <xsl:choose>
  206.                                                                 <xsl:when test = "contains(@type, ':')">
  207.                                                                     <xsl:value-of select="substring-after(@type, ':')" />
  208.                                                                 </xsl:when>
  209.                                                                 <xsl:otherwise>
  210.                                                                     <xsl:value-of select="@type" />
  211.                                                                 </xsl:otherwise>
  212.                                                             </xsl:choose>
  213.                                                         </xsl:attribute>
  214.                                                     </xsl:if>
  215.                                                 </element>
  216.                                             </xsl:for-each>
  217.                                     </sequence>
  218.                                 </complexType>
  219.                             </xsl:if>
  220.  
  221.                         </element>
  222.                     </xsl:for-each>
  223.                 </schema>
  224.             </types>
  225.         </xsl:for-each>
  226.  
  227.         <!--
  228.         =========================================================
  229.         get top level documentation node
  230.             in case there are no services (just portTypes) this will be used
  231.         =========================================================
  232.         -->
  233.         <xsl:for-each select="wsdl:documentation">
  234.             <documentation>
  235.                 <xsl:value-of select="."/>
  236.             </documentation>
  237.         </xsl:for-each>
  238.  
  239.     </xsl:template>
  240.  
  241. <xsl:template match="text()" />
  242. </xsl:stylesheet>
  243.